﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using ModuleDALCore;

namespace DAL
{
	public class CT_TOATHUOCBNDAO : DALBase
	{
		public CT_TOATHUOCBNDAO()
		{
			this.OpenConnect();
		}

		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPCT_TOATHUOCBN"; }
			set { _SpName = value; }
		}

		public List<CT_TOATHUOCBN> GetListCT_TOATHUOCBN(CT_TOATHUOCBN cttt)
		{
			List<CT_TOATHUOCBN> CT_TOATHUOCBN = new List<CT_TOATHUOCBN>();
			dt = new DataTable();

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cttt, null), ConvertClassToArray.GetValues(cttt, 0));
				CT_TOATHUOCBN = (List<CT_TOATHUOCBN>)ConvertDatatableToList.ConvertTo<CT_TOATHUOCBN>(dt);
			}

			catch { return null; }

			return CT_TOATHUOCBN;
		}
		public DataTable GetListCT_TOATHUOCBNs(CT_TOATHUOCBN cttt)
		{
			dt = new DataTable();

			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cttt, null), ConvertClassToArray.GetValues(cttt, 0));
			}

			catch { return null; }

			return dt;
		}

		public bool INSERT(CT_TOATHUOCBN cttt)
		{
			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cttt, null), ConvertClassToArray.GetValues(cttt, 1)) == 1);

			}
			catch { return false; }
		}

		public bool UPDATE(CT_TOATHUOCBN cttt)
		{
			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cttt, null), ConvertClassToArray.GetValues(cttt, 2)) == 1);

			}
			catch { return false; }
		}

		public bool DELETE(CT_TOATHUOCBN cttt)
		{
			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cttt, null), ConvertClassToArray.GetValues(cttt, 3)) == 1);

			}
			catch { return false; }
		}
	}
}
